package com.twu.biblioteca.options;

import com.twu.biblioteca.Book;
import com.twu.biblioteca.BookRepository;
import com.twu.biblioteca.Option;
import com.twu.biblioteca.UserInterface;

import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * User: aulme
 * Date: 28/06/2013
 * Time: 18:31
 * To change this template use File | Settings | File Templates.
 */
public class ViewBooksInCollectionOption implements Option {
    private UserInterface mockUi;
    private BookRepository bookRepository;

    public ViewBooksInCollectionOption(UserInterface mockUi, BookRepository bookRepository) {
        this.mockUi = mockUi;
        this.bookRepository = bookRepository;
    }

    @Override
    public void Execute() {
        Collection<Book> books = this.bookRepository.getAll();
        int i = 1;
        this.mockUi.showMessage("Books in collection:");
        for (Book book : books) {
            this.mockUi.showMessage(i + ") " + book.getName());
            i++;
        }
    }

    @Override
    public String toString() {
        return "View books in collection";
    }
}
